package com.nasarius.bank.scorecard.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.nasarius.bank.scorecard.dao.UserBankDAO;
import com.nasarius.bank.scorecard.domain.UserBank;
import com.nasarius.bank.scorecard.domain.UserBankExample;
@Repository
public class UserBankDAOImpl extends SqlMapClientDaoSupport implements UserBankDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
	@Autowired
    public UserBankDAOImpl(/*@Qualifier("sqlMapClient")*/SqlMapClient sqlMapClient) {
        super();
        setSqlMapClient(sqlMapClient);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int countUserBankByExample(UserBankExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("user_banks.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int deleteUserBankByExample(UserBankExample example) {
        int rows = getSqlMapClientTemplate().delete("user_banks.ibatorgenerated_deleteByExample", example);
        return rows;
    }
    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int deleteUserBank(String username) {
    	UserBank record = new UserBank();
    	record.setUsername(username);
        int rows = getSqlMapClientTemplate().delete("user_banks.ibatorgenerated_deleteUserBank", record);
        return rows;
    }
    
    public void insertUserBank(UserBank record) {
        getSqlMapClientTemplate().insert("user_banks.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public void insertUserBankSelective(UserBank record) {
        getSqlMapClientTemplate().insert("user_banks.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    @SuppressWarnings("unchecked")
    public List<UserBank> selectUserBankByExample(UserBankExample example) {
        List<UserBank> list = getSqlMapClientTemplate().queryForList("user_banks.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserBankByExampleSelective(UserBank record, UserBankExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("user_banks.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    public int updateUserBankByExample(UserBank record, UserBankExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("user_banks.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table user_banks
     *
     * @ibatorgenerated Sat Apr 09 15:48:39 IST 2011
     */
    private static class UpdateByExampleParms extends UserBankExample {
        private Object record;

        public UpdateByExampleParms(Object record, UserBankExample example) {
            super(example);
            this.record = record;
        }

        @SuppressWarnings("unused")
		public Object getRecord() {
            return record;
        }
    }

    @SuppressWarnings("unchecked")
	public List<UserBank> selectUserBank(String username) {
		UserBank userBank = new UserBank();
		userBank.setUsername(username);
		List<UserBank> list = getSqlMapClientTemplate().queryForList("user_banks.ibatorgenerated_selectUserBank", userBank);
		return list;
	}
}